// 时间格式化
const formatDate = function(fmt,date){
    let ret;
    if(!date){
        date = new Date()
    }
    let opt = {
        "Y+":date.getFullYear().toString(),
        "M+":(date.getMonth() + 1).toString(),
        "D+":date.getDate().toString(),
        "h+":date.getHours().toString(),
        "m+":date.getMinutes().toString(),
        "s+":date.getSeconds().toString()
    }
    for(var k in opt){
        ret = new RegExp("("+ k +")").exec(fmt)
        if(ret){
            fmt = fmt.replace(ret[0], (ret[0].length == 1) ? (opt[k]) : (opt[k].padStart(ret[0].length, "0")))
        }
    }
    return fmt
};
export {formatDate}